@extends('Home.varieties.layout')
@section('title','中药材品种_中草药品种-品种大全--中药材天地网')
@section('con')
    
    <!-- 拼音搜索css -->
    <style type="text/css">
        /*名称缩写*/
        .pinyin{
            border: 1px solid #ededed;
            background: #f9f9f9;
            margin-top: -1px;
            padding: 6px;
            z-index: 3;
            position: relative;
            font-size: 16px;
            display: block;
            color: #333;
            font-family: '宋体',arial;
        }

        .uc{
            height: 22px;
            display: block;
            line-height: 22px;
            float: left;
            padding: 0 6px;
        }
        /*首字母被选中*/
        .selected{
            border: 1px solid #ededed;
            border-bottom: 1px solid #f3f9ff;
            background: #f3f9ff;
        }
        /*品种名*/
        .name{
            display: inline-block;
            padding: 0 10px;
            font-size: 14px;
            line-height: 28px;
            white-space: nowrap;
            overflow: hidden;
            zoom: 1;
            vertical-align: middle;
            width: 90px;
        }
    </style>


    <div id="body">
        <section class="content-wrapper main-content clear-fix"> 
            <div class="w ovh">
                <div class="adArea">
                    <a href="http://zhuanti.zyctd.com/ZT201608d/" target="_blank">
                        <img src="http://imgServer.zyctd.com/Images/2016/9/5/10/3/ed0a97c5bf814ac5806433cd3157e806.jpg" alt="品种大全" border="0">
                    </a>
                </div>
                <div class="crumbs">
                    <span class="g9">当前位置：</span><a class="g9" href="{{url('/home/')}}">首页</a> &gt; 品种大全
                </div>
                <!-- 拼音查找 -->
                <div class="row mb20 dxjsb">
                    <div class="indexTitle"><strong>拼音查找</strong></div>
                    <div class="bdBox l">
                        <div class="ovh py f16">
                            <div class="pyTop ovh">
                            @foreach($first as $k => $v)
                                <!-- <span style="display:none">onclick="ZYCLib.Breeds.Handdler.GetSubLetter(this,'{{ucfirst($v -> first)}}')"</span> -->
                                <a class="first" href="javascript:void(0);">{{ucfirst($v -> first)}}</a>
                            @endforeach
                            </div>
                            @foreach($first as $k => $v)
                                <div class="pyCon ovh none" id="divMCodexSubLetters"></div>
                            @endforeach
                        </div>
                        <div class="secBreeds none" id="divPinyinMCodex" style="padding: 0;"></div>
                        <div class="secBreeds none" id="divPinyinMCodex" style="padding: 0;"></div>
                    </div>
                </div>
                <!-- 属性查找  -->
                <div class="row mt20 dxjsb">
                    <div class="indexTitle"><strong>属性查找</strong></div>
                    <div class="attribute f14">
                    @foreach($sx as $k => $v)
                        <a class="sx" href="javascript:void(0);">{{$v}}</a>
                    @endforeach
                    </div>
                    <div class="attrCon none" id="PropertyDiv">
                        <p class="tc f20"><strong id="PropertyName"></strong></p>
                        <ul class="f14" id="proData"></ul>
                    </div>
                </div>
                <!-- 首字母 -->
                <div class="row typeFinder mt20 dxjsb">
                    <div class="indexTitle bdBottom"><strong>综合{{$size}}品种</strong></div>
                    <div class="ovh breedbox">
                    @foreach($first as $fk => $fv)
                        <div class="shape l ">
                            <div class="type typeB">
                                <strong><a href="javascript:void 0;">{{ucfirst($fv -> first)}}</a></strong>
                            </div>
                        @foreach($name[$fv -> first] as $nk => $nv)
                            <a target="_blank" href="{{url('/home/varieties/list',[$nv])}}" title="">{{$nv}}</a>
                            <span class="shu">|</span>
                        @endforeach
                        </div>
                    @endforeach
                    </div>
                </div>
                <div class="adArea">
                </div>
            </div>
        </section>
    </div>
    
    <!-- 首字母单击事件js -->
    <script type="text/javascript">
        $.ajaxSetup({
            headers:{
                'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content')
            }
        });
        $(".pyTop .first").click(function(){
            $(this).addClass('selected').addClass('uc').siblings().removeClass('selected');
            var index = $(this).index();
            // alert(index);
            $(".py .pyCon").eq(index).addClass('pinyin').siblings().removeClass('pinyin');
            $(".py").next(".secBreeds").css('display','block');
            var py = $(this).html();
            // alert(py);

            //首字母ajax返回数据
            $.ajax({
                url: '/home/varieties/ajax',
                type: 'post',
                dataType: 'json',
                data: {"pinyin":py},
                success:function(data){
                    // console.log(data);
                    var html = "<a class='first' href='javascript:void(0)'>"+py+"</a>";
                    var alln = ""; 
                    for(var i = 0;i<data.length;i++){
                        if(i == 0){
                            for(var j = 0;j<data[i].length;j++){
                                console.log(data[i]);
                                html += "<a class='pyname' href='javascript:void(0)'>"+data[i][j].pinyin+"</a>";
                                // alln += "<a class='name' href='/home/varieties/list/"+data[i].name+"'>"+data[i].name+"</a>"; 
                            }
                        }else if(i == 1){
                            for(var j = 0;j<data[i].length;j++){
                                console.log(data[i]);
                                // html += "<a class='pyname' href='javascript:void(0)'>"+data[i][j].pinyin+"</a>";
                                alln += "<a class='name' href='/home/varieties/list/"+data[i][j].name+"'>"+data[i][j].name+"</a>"; 
                            }
                        }
                    }
                    $(".py .pyCon").eq(index).html('').append(html);
                    $(".py").next(".secBreeds").html('').append(alln);
                },
                error:function(data){

                },
                timeout:2000,
                async:true
            })

            //名字缩写ajax

        })
    </script>

    <!-- 名称缩写单击事件 -->
    <script type="text/javascript">
        // console.log($(".pyname"));
        // console.log($(".pyCon .pyname"));
        $(".pinyin .pyname").live('click',function(){
            var pinyin = $(this).html();
            // alert(pinyin);
            $.ajax({
                url: '/home/varieties/name',
                type: 'post',
                dataType: 'json',
                data: {"name":pinyin},
                success:function(data){
                    // alert('ddd');
                    var alln = ""; 
                    for(var i = 0;i<data.length;i++){
                        alln += "<a class='name' href='/home/varieties/list/"+data[i].name+"'>"+data[i].name+"</a>"; 
                    }
                    $(".py").next(".secBreeds").html('').append(alln);
                },
                error:function(data){
                    // alert('dd');
                },
                timeout:2000,
                async:true
            })
        });
    </script>
    
    <!-- 药材属性特点 -->
    <script type="text/javascript">
        // console.log($(".sx"));
        $(".sx").click(function(){
            // alert(123);
            var index = $(this).index();
            var txt = $(this).html();
            $(".attrCon").css('display','block').find('p').find('strong').html(txt);
            $.ajax({
                url: '/home/varieties/properties',
                type: 'post',
                dataType: 'json',
                data: {"sx":txt},
                success:function(data){
                    // alert('ddd');
                    var alln = ""; 
                    for(var i = 0;i<data.length;i++){
                        alln += "<li><a class='name' href='/home/varieties/list/"+data[i].name+"'>"+data[i].name+"</a></li>"; 
                    }
                    $(".attrCon ul").html('').append(alln);
                },
                error:function(data){
                    // alert('dd');
                },
                timeout:2000,
                async:true
            });
            
        });
    </script>

    <!-- // 去除最后一个品种后面的'|' -->
    <script type="text/javascript">
        $(".shape .shu:last-child").html('');
    </script>
@endsection